# 爬取果壳网
# 导入请求
import requests
from selenium import webdriver
import time
# chromedriver 配置相关的
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
# 定时延迟的
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from bs4 import BeautifulSoup
#获取验证码的url, 一般指登录页面
loginUrl = 'https://yueshushu.top/Stock/realtrade/rlogin'

# 登录方法
login_url = 'https://www.yueshushu.top/StockApi/tradeUser/login'

saveImage = 'captcha.jpg'

# 获取验证码
def getCaptcha(loginPageHtml,filePath):
    soup = BeautifulSoup(loginPageHtml, 'html.parser')
    img64 = soup.findAll("img")[0].get('src')
    print(f'获取图片的base64: {img64}')
    return getCodeByCjyWith64(img64)

# 将base64 进行去掉前缀处理
def process_base64(base64):
    if base64.startswith("data:image"):
        # 找到第一个逗号的位置
        comma_index = base64.find(',')
        if comma_index != -1:
            # 从逗号之后开始截取子字符串
            base64 = base64[comma_index + 1:]
    return base64
# 根据超级鹰获取图片验证码,通过 本地图片
def getCodeByCjyWith64(base64_str):
    api_url = "http://upload.chaojiying.net/Upload/Processing.php"
    # 构造请求参数
    payload = {
        'user': 'yueshushu',
        'pass': 'yjl1314cjy',
        'softid': '0f1aad8b4659e731c672f3024e89b5cd',
        'codetype': 1004,  # 识别类型，1004 表示纯数字
        'file_base64': process_base64(base64_str)
    }
    # 发送 POST 请求
    response = requests.post(api_url, data=payload)
    print(f'获取请求结果: {response.content.decode()}')
    # 检查响应
    if response.status_code == 200:
        result = response.json()
        if result['err_no'] == 0:
            return result['pic_str']
        else:
            print(f"识别失败：{result['err_msg']}")
            return None
    else:
        print(f"请求失败，状态码：{response.status_code}")
        return None
# 获取等待页
def getTimePageHtml(loginUrl):
    # chrome_options = Options()
    # # 设置 ChromeDriver 的路径
    # service = Service(executable_path='E:\\PythonGit\\Python_Crawler\\learn\\chromedriver\\chromedriver.exe')
    #
    # # 创建 WebDriver 实例
    # driver = webdriver.Chrome(service=service, options=chrome_options)
    #
    # # 访问一个网页
    # driver.get(loginUrl)
    #
    # # 获取 capabilities
    # capabilities = driver.capabilities
    #
    # # 访问 capabilities 中的 browserName
    # browser_name = capabilities.get("browserName")
    #
    # print(f"Browser Name: {browser_name}")
    #
    # # 休眠10s，显式的
    # wait = WebDriverWait(driver, 10)
    # # 获取内容,使用 driver.page_source
    # # 等待,直到id 出现
    # element = wait.until(EC.presence_of_all_elements_located((By.ID, 'header')))
    # htmlContent = driver.page_source
    # print(f'打印内容: {htmlContent}')
    # return htmlContent
    content = '''
    

<div id="app"><div data-v-1c734758="" class="app-wrapper openSidebar"><!----> <div data-v-1c734758="" class="sidebar-container el-scrollbar"><div class="scrollbar-wrapper el-scrollbar__wrap" style="margin-bottom: -17px; margin-right: -17px;"><div class="el-scrollbar__view"><ul role="menubar" class="el-menu" show-timeout="200" style="background-color: rgb(48, 65, 86);"><!----><!----><!----><!----><!----><!----><!----><div class="menu-wrapper"><li role="menuitem" aria-haspopup="true" class="el-submenu"><div class="el-submenu__title" style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-example"></use></svg><span>股票信息模块</span><i class="el-submenu__icon-arrow el-icon-arrow-down"></i></div><ul role="menu" class="el-menu el-menu--inline" style="background-color: rgb(48, 65, 86); display: none;"> <a href="/Stock/stock/stock" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票模块</span></li></a><a href="/Stock/stock/selected" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>自选股票</span></li></a><a href="/Stock/stock/stock_history" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>自选股票最近交易记录</span></li></a><a href="/Stock/stock/stock_update_log" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票更新日志</span></li></a></ul></li></div><div class="menu-wrapper"><li role="menuitem" aria-haspopup="true" class="el-submenu"><div class="el-submenu__title" style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-example"></use></svg><span>板块/概念模块</span><i class="el-submenu__icon-arrow el-icon-arrow-down"></i></div><ul role="menu" class="el-menu el-menu--inline" style="background-color: rgb(48, 65, 86); display: none;"> <a href="/Stock/bk/bkStock" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票关联版块查询</span></li></a><a href="/Stock/bk/bkHistory" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票板块历史查询</span></li></a><a href="/Stock/bk/gnHistory" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票概念历史查询</span></li></a><a href="/Stock/bk/bktop" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>板块涨幅度查询</span></li></a><a href="/Stock/bk/gntop" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>概念涨幅度查询</span></li></a></ul></li></div><div class="menu-wrapper"><li role="menuitem" aria-haspopup="true" class="el-submenu"><div class="el-submenu__title" style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-example"></use></svg><span>统计分析功能</span><i class="el-submenu__icon-arrow el-icon-arrow-down"></i></div><ul role="menu" class="el-menu el-menu--inline" style="background-color: rgb(48, 65, 86); display: none;"> <a href="/Stock/stat/stock_stat" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>周和图表统计</span></li></a><a href="/Stock/stat/history_stat" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票历史记录统计</span></li></a><a href="/Stock/stat/history_ten10_stat" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>最近十天交易汇总</span></li></a><a href="/Stock/stat/history_pool" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>最近股票池汇总</span></li></a><a href="/Stock/stat/bk_stat" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票版块统计</span></li></a><a href="/Stock/stat/gn_stat" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票概念统计</span></li></a><a href="/Stock/stat/stock_money" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票资金统计</span></li></a><a href="/Stock/stat/analyze" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>日常数据分析</span></li></a><a href="/Stock/stat/zb_stat" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>指标数据分析</span></li></a></ul></li></div><div class="menu-wrapper"><li role="menuitem" aria-haspopup="true" class="el-submenu"><div class="el-submenu__title" style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-example"></use></svg><span>股票策略功能</span><i class="el-submenu__icon-arrow el-icon-arrow-down"></i></div><ul role="menu" class="el-menu el-menu--inline" style="background-color: rgb(48, 65, 86); display: none;"> <a href="/Stock/strategy/strategy_cache" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>策略缓存</span></li></a><a href="/Stock/strategy/strategy_db" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>历史筛选数据</span></li></a><a href="/Stock/strategy/strategy_back" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票回测数据</span></li></a><a href="/Stock/strategy/strategy_choose" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票筛选</span></li></a></ul></li></div><div class="menu-wrapper"><li role="menuitem" aria-haspopup="true" class="el-submenu"><div class="el-submenu__title" style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-example"></use></svg><span>小工具模块</span><i class="el-submenu__icon-arrow el-icon-arrow-down"></i></div><ul role="menu" class="el-menu el-menu--inline" style="background-color: rgb(48, 65, 86); display: none;"> <a href="/Stock/tools/clear" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票清仓</span></li></a><a href="/Stock/tools/cover" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票补仓</span></li></a><a href="/Stock/tools/reduce" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>股票减仓</span></li></a></ul></li></div><div class="menu-wrapper"><li role="menuitem" aria-haspopup="true" class="el-submenu"><div class="el-submenu__title" style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-example"></use></svg><span>系统配置</span><i class="el-submenu__icon-arrow el-icon-arrow-down"></i></div><ul role="menu" class="el-menu el-menu--inline" style="background-color: rgb(48, 65, 86); display: none;"> <a href="/Stock/sys/holiday" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>假期查询</span></li></a><a href="/Stock/sys/config" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>全局参数配置</span></li></a><a href="/Stock/sys/cache" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>缓存key列表查询</span></li></a><a href="/Stock/sys/jobInfo" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>执行任务信息</span></li></a></ul></li></div><div class="menu-wrapper"><li role="menuitem" aria-haspopup="true" class="el-submenu"><div class="el-submenu__title" style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-example"></use></svg><span>虚拟业务处理</span><i class="el-submenu__icon-arrow el-icon-arrow-down"></i></div><ul role="menu" class="el-menu el-menu--inline" style="background-color: rgb(48, 65, 86); display: none;"> <a href="/Stock/mocktrade/position" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>持仓信息</span></li></a><a href="/Stock/mocktrade/entrust" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>今日委托信息</span></li></a><a href="/Stock/mocktrade/hisentrust" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>历史委托信息</span></li></a><a href="/Stock/mocktrade/deal" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>今日成交记录</span></li></a><a href="/Stock/mocktrade/hisdeal" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>历史成交记录</span></li></a><a href="/Stock/mocktrade/hisposition" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>历史持仓记录</span></li></a><a href="/Stock/mocktrade/hismoney" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>历史金额记录</span></li></a></ul></li></div><div class="menu-wrapper"><li role="menuitem" aria-haspopup="true" class="el-submenu is-active is-opened" aria-expanded="true"><div class="el-submenu__title" style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-example"></use></svg><span>真实业务处理</span><i class="el-submenu__icon-arrow el-icon-arrow-down"></i></div><ul role="menu" class="el-menu el-menu--inline" style="background-color: rgb(48, 65, 86);" data-old-padding-top="" data-old-padding-bottom="" data-old-overflow=""> <a href="/Stock/realtrade/rlogin" class="router-link-exact-active router-link-active"><li role="menuitem" tabindex="-1" class="el-menu-item is-active" style="padding-left: 40px; color: rgb(64, 158, 255); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>交易用户登录</span></li></a><a href="/Stock/realtrade/position" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>持仓信息</span></li></a><a href="/Stock/realtrade/entrust" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>今日委托信息</span></li></a><a href="/Stock/realtrade/hisentrust" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>历史委托信息</span></li></a><a href="/Stock/realtrade/deal" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>今日成交记录</span></li></a><a href="/Stock/realtrade/hisdeal" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>历史成交记录</span></li></a><a href="/Stock/realtrade/hisposition" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>历史持仓记录</span></li></a><a href="/Stock/realtrade/hismoney" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>历史金额记录</span></li></a></ul></li></div><div class="menu-wrapper"><li role="menuitem" aria-haspopup="true" class="el-submenu"><div class="el-submenu__title" style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-example"></use></svg><span>用户资源配置</span><i class="el-submenu__icon-arrow el-icon-arrow-down"></i></div><ul role="menu" class="el-menu el-menu--inline" style="background-color: rgb(48, 65, 86); display: none;"> <a href="/Stock/user/user" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>用户</span></li></a><a href="/Stock/user/role" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>角色</span></li></a></ul></li></div><div class="menu-wrapper"><li role="menuitem" aria-haspopup="true" class="el-submenu"><div class="el-submenu__title" style="padding-left: 20px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-example"></use></svg><span>扩展功能配置</span><i class="el-submenu__icon-arrow el-icon-arrow-down"></i></div><ul role="menu" class="el-menu el-menu--inline" style="background-color: rgb(48, 65, 86); display: none;"> <a href="/Stock/extInfo/user" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>扩展用户</span></li></a><a href="/Stock/extInfo/interInfo" class=""><li role="menuitem" tabindex="-1" class="el-menu-item" style="padding-left: 40px; color: rgb(191, 203, 217); background-color: rgb(48, 65, 86);"><svg data-v-22425877="" aria-hidden="true" class="svg-icon"><use data-v-22425877="" xlink:href="#icon-table"></use></svg><span>扩展接口</span></li></a></ul></li></div></ul></div></div><div class="el-scrollbar__bar is-horizontal"><div class="el-scrollbar__thumb" style="transform: translateX(0%);"></div></div><div class="el-scrollbar__bar is-vertical"><div class="el-scrollbar__thumb" style="height: 53.4759%; transform: translateY(100%);"></div></div></div> <div data-v-1c734758="" class="main-container"><ul data-v-17ca586a="" data-v-1c734758="" role="menubar" class="navbar el-menu--horizontal el-menu"><div data-v-31bb942f="" data-v-17ca586a="" class="hamburger-container" tabindex="0"><svg data-v-31bb942f="" t="1492500959545" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1691" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64" class="hamburger is-active"><path data-v-31bb942f="" d="M966.8023 568.849776 57.196677 568.849776c-31.397081 0-56.850799-25.452695-56.850799-56.850799l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 543.397081 998.200404 568.849776 966.8023 568.849776z" p-id="1692"></path> <path data-v-31bb942f="" d="M966.8023 881.527125 57.196677 881.527125c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.849776 56.850799-56.849776l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.849776l0 0C1023.653099 856.07443 998.200404 881.527125 966.8023 881.527125z" p-id="1693"></path> <path data-v-31bb942f="" d="M966.8023 256.17345 57.196677 256.17345c-31.397081 0-56.850799-25.452695-56.850799-56.849776l0 0c0-31.397081 25.452695-56.850799 56.850799-56.850799l909.605623 0c31.397081 0 56.849776 25.452695 56.849776 56.850799l0 0C1023.653099 230.720755 998.200404 256.17345 966.8023 256.17345z" p-id="1694"></path></svg></div> <div data-v-71abea56="" data-v-17ca586a="" aria-label="Breadcrumb" role="navigation" class="el-breadcrumb app-breadcrumb" tabindex="0"><span data-v-71abea56=""><span data-v-71abea56="" class="el-breadcrumb__item"><span role="link" class="el-breadcrumb__inner"><a data-v-71abea56="">首页</a></span><span role="presentation" class="el-breadcrumb__separator">/</span></span><span data-v-71abea56="" class="el-breadcrumb__item"><span role="link" class="el-breadcrumb__inner"><a data-v-71abea56="">真实业务处理</a></span><span role="presentation" class="el-breadcrumb__separator">/</span></span><span data-v-71abea56="" class="el-breadcrumb__item"><span role="link" class="el-breadcrumb__inner"><span data-v-71abea56="" class="no-redirect">交易用户登录</span></span><span role="presentation" class="el-breadcrumb__separator">/</span></span></span></div> <div data-v-17ca586a="" class="avatar-container el-dropdown" tabindex="0"><div data-v-17ca586a="" class="avatar-wrapper el-dropdown-selfdefine" aria-haspopup="list" aria-controls="dropdown-menu-9367" role="button" tabindex="0"><span data-v-17ca586a="">欢迎您: <span data-v-17ca586a="" style="font-size: 24px; color: red;">yjl  </span></span> <i data-v-17ca586a="" class="el-icon-caret-bottom"></i></div> <ul data-v-17ca586a="" class="el-dropdown-menu el-popper user-dropdown" id="dropdown-menu-9367" style="display: none;"><a data-v-17ca586a="" href="/Stock/" class="inlineBlock router-link-active"><li data-v-17ca586a="" tabindex="-1" class="el-dropdown-menu__item">
          首页
        </li></a> <li data-v-17ca586a="" tabindex="-1" class="el-dropdown-menu__item el-dropdown-menu__item--divided"><span data-v-17ca586a="" style="display: block;"> 修改个人信息</span></li> <li data-v-17ca586a="" tabindex="-1" class="el-dropdown-menu__item el-dropdown-menu__item--divided"><span data-v-17ca586a="" style="display: block;"> 退出 </span></li></ul></div> <div data-v-17ca586a="" class="el-dialog__wrapper" tabindex="0" style="display: none;"><div class="el-dialog" style="margin-top: 15vh;"><div class="el-dialog__header"><span class="el-dialog__title">维护用户</span><button type="button" aria-label="Close" class="el-dialog__headerbtn"><i class="el-dialog__close el-icon el-icon-close"></i></button></div><!----><div class="el-dialog__footer"><div data-v-17ca586a="" class="dialog-footer"><button data-v-17ca586a="" type="button" class="el-button el-button--default"><!----><!----><span>取消</span></button> <button data-v-17ca586a="" type="button" class="el-button el-button--primary"><!----><!----><span>确认</span></button></div></div></div></div></ul> <section data-v-7f3d9728="" data-v-1c734758="" class="app-main"><section data-v-a351680e="" data-v-7f3d9728="" class="el-container is-vertical" style="height: 80%;"><main data-v-a351680e="" class="el-main" style="padding-top: 200px;"><div data-v-a351680e="" class="el-col el-col-8 el-col-offset-1"><div data-v-a351680e=""><h2 data-v-a351680e="">欢迎登录  <span data-v-a351680e="" class="relationName"><a data-v-a351680e="" href="https://www.yueshushu.top">两个蝴蝶飞</a></span>  自用交易软件</h2></div> <div data-v-a351680e="" class="mar30"><p data-v-a351680e="" style="font-size: 18px; color: red;">股票有风险,入市需谨慎</p></div></div> <div data-v-a351680e="" class="el-col el-col-10"><div data-v-a351680e=""><form data-v-a351680e="" class="el-form loginForm el-form--label-left" auto-complete="on"><div data-v-a351680e="" class="el-form-item"><!----><div class="el-form-item__content"><div data-v-a351680e="" class="el-col el-col-10 el-col-offset-3"><label data-v-a351680e="" class="control-label">证券账号已经提前绑定,无需输入:</label></div><!----></div></div> <div data-v-a351680e="" class="el-form-item"><!----><div class="el-form-item__content"><div data-v-a351680e="" class="el-col el-col-10 el-col-offset-3"><label data-v-a351680e="" class="control-label">证券密码已经提前写入,无需输入:</label></div><!----></div></div> <div data-v-a351680e="" class="el-form-item"><!----><div class="el-form-item__content"><div data-v-a351680e="" class="el-col el-col-3">
              验证码:
            </div> <div data-v-a351680e="" class="el-col el-col-8"><div data-v-a351680e="" class="el-input"><!----><input type="text" autocomplete="off" class="el-input__inner"><!----><!----><!----></div></div> <div data-v-a351680e="" class="yzm el-col el-col-12"><img data-v-a351680e="" alt="" src=""></div><!----></div></div> <div data-v-a351680e="" class="el-form-item"><!----><div class="el-form-item__content"><div data-v-a351680e="" class="el-col el-col-24 el-col-offset-3"><button data-v-a351680e="" type="button" class="el-button el-button--primary" element-loading-text="登录中,请稍候..." style="width: 35%;"><!----><!----><span>
                登录
              </span></button></div><!----></div></div> <div data-v-a351680e="" class="el-form-item"><!----><div class="el-form-item__content"><div data-v-a351680e="" class="el-col el-col-24 el-col-offset-5">
              本软件不提供注册服务。 如有需要,请 <a data-v-a351680e="" href="tencent://message/?uin=1290513799&amp;Exe=QQ&amp;Site=Simplelife&amp;Menu=ye"><span data-v-a351680e="" class="relationUser">联系系统管理员</span></a></div><!----></div></div></form></div></div></main> <footer data-v-a351680e="" class="el-footer" style="height: 60px;"><div data-v-a351680e="" class="copyText"><small data-v-a351680e="">© 2021 <a data-v-a351680e="" href="https://blog.csdn.net/yjltx1234csdn" target="_blank">岳叔叔</a></small><br data-v-a351680e=""></div></footer></section></section></div></div></div>
    
    '''
    return content
#构建登录参数
def getLoginParam (session,loginUrl):
    print(f' 访问登录页面: {loginUrl}')
    loginPageHtml = getTimePageHtml(loginUrl)
    soup = BeautifulSoup(loginPageHtml, 'html.parser')
  #  csrf_token = soup.find('input', {'name': 'csrf_token'}).get('value')
   # captcha_rand = soup.find('input', {'name': 'captcha_rand'}).get('value')
    captcha = getCaptcha(loginPageHtml,'gk.png')
    print(f'验证码是: {captcha}')
    data = {
       # 'csrf_token': csrf_token,
       # 'captcha_rand': captcha_rand,
        "id": 1,
        "readAgreement": "1",
        'identifyCode': captcha
    }
    return data
# 获取到验证码, 要使用session
session = requests.Session()
params = getLoginParam(session,loginUrl)
print(f'\n 获取参数: {params} \n')
header = {
    'Authorization': 'd2aed769858763116dc324736bbcad6f'
}
loginResponse = session.post(login_url,json= params, headers = header)
print(f'登录之后，网站返回 {loginResponse.content.decode()}')
moneyResonse = session.post('https://www.yueshushu.top/StockApi/tradeMoney/info',json = {'mockType':0})
print(f'获取Money信息 {moneyResonse.content.decode()}')